package com.github.cakin.shiro.chapter21.entity;

import java.io.Serializable;

/**
 * @className: UserRunAs
 * @description: UserRunAs 实体类
 * 该实体定义了授予身份帐号（老板）与被授予身份帐号（秘书）的关系，意思是 秘书 帐号将可以假装为 老板 帐号的身份进行访问。
 * @date: 2020/5/29
 * @author: cakin
 */
public class UserRunAs implements Serializable {
    /**
     * 授予身份帐号
     */
    private Long fromUserId;
    /**
     * 被授予身份帐号
     */
    private Long toUserId;
    /**
     * 常量
     */
    private static final int NUM31 = 31;

    public Long getFromUserId() {
        return fromUserId;
    }

    public void setFromUserId( Long fromUserId ) {
        this.fromUserId = fromUserId;
    }

    public Long getToUserId() {
        return toUserId;
    }

    public void setToUserId( Long toUserId ) {
        this.toUserId = toUserId;
    }

    @Override
    public boolean equals( Object o ) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        UserRunAs userRunAs = (UserRunAs) o;

        if (fromUserId != null ? !fromUserId.equals(userRunAs.fromUserId) : userRunAs.fromUserId != null) {
            return false;
        }
        if (toUserId != null ? !toUserId.equals(userRunAs.toUserId) : userRunAs.toUserId != null) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = fromUserId != null ? fromUserId.hashCode() : 0;
        result = NUM31 * result + (toUserId != null ? toUserId.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "UserRunAs{"
                + "fromUserId=" + fromUserId
                + ", toUserId=" + toUserId
                + '}';
    }
}
